import Router from "vue-router"
import Vue from "vue"

Vue.use(Router);  // 全局挂载 router-view router-link 组件 
// 在this中添加$router $route

const router = new Router({
    mode: "history",
    routes:[
        {
            path:'/',
            redirect:'/home'
        },
        {
            path:'/registry',
            name:'home',
            meta:{
                title:"注册"
            },
            component:()=> import("@/views/registry")
        },
        {
            path:'/login',
            name:'login',
            meta:{
                title:"登录"
            },
            component:()=> import("@/views/login")
        },
        {
            path:'/home',
            name:'home',
            meta:{
                title:"首页"
            },
            component:()=> import("@/views/home")
        },
        {
            path:'/addresslist',
            name:'addressList',
            meta:{
                title:"地址列表"
            },
            component:()=> import("@/views/addressList")
        },
        {
            path:'/address/:type',
            name:'Addaddress',
            meta:{
                title:"添加地址"
            },
            component:()=> import("@/views/addAddress")
        }
    ]
})

router.beforeEach((to,from,next) => {
    document.title = to.meta?.title
    next();
})

export default router;


// egg
// app
//    controller
//    service
//    public
//    extend
//        helper
//    middleware
//        ()=>async(ctx,next) => await next()
//    router.js 路由配置
// config
//    config.default.js
//    plugin.js